package com.googlecode.mbhsrobopro.controller.gamepad;

import net.java.games.input.ControllerEnvironment;

public class ControllerTest {

	public static void main(String[] args) {
		PS2Controller.initDirectionMap();
		
		ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
		
		PS2Controller one = new PS2Controller(ce.getControllers()[ce.getControllers().length - 2]);
		
		while (true) {
			one.pollController();
			
			float mid = (float) (1 / Math.sqrt(2));
			StickLocation s = one.getLeftStickState();
			
			if (s.isAtOrigin()) {
				System.out.print("Not Moving");
			} else if (s.x >= -mid && s.x <= mid) {
				if (s.y < 0) {
					System.out.print("Moving Forward");
				} else {
					System.out.print("Moving Backward");
				}
			} else if (s.x < -mid) {
				System.out.print("Turning Left");
			} else {
				System.out.print("Turning Right");
			}
			
			System.out.println(": " + s);
			
//			if (!one.isLeftStickNeutral())
//				System.out.print("Left Stick At: " + one.getLeftStickState() + " || ");
//			
//			if (!one.isRightStickNeutral())
//				System.out.print("Right Stick At: " + one.getRightStickState() + " || ");
//			
//			System.out.print("D-Pad at " + one.getDPadDirection() + " || ");
//			
//			for (Button b : Button.values())
//				if (one.getButtonState(b))
//					System.out.print(b.toString() + " pressed || ");
//			
//			System.out.println();			
		}

	}

}
